<template>
  <div class="jxkcsh">
    <div class="select-module">
      <el-card>
        <i class="el-icon-search" style="font-size: 30px; font-weight: bold; color: #409eff; margin: 0 20px 0 0; position: relative; top: 5px;"></i>
        <div class="select-item">
          <span>课程类别:</span>
          <el-select v-model="coursevalue1" placeholder="请选择">
            <el-option
              v-for="item in optionsValue1"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </div>
        <div class="select-item">
          <span>课程名称:</span>
          <el-input v-model="coursevalue4" placeholder="请输入">
          </el-input>
        </div>
        <div class="fr">
          <el-button type="primary" @click="findQuery">查询</el-button>
          <el-button type="danger" @click="clearParams">清除条件</el-button>
        </div>
      </el-card>
    </div>
    <el-card>
      <!--筛选条件-->
      <div class="table-module">
        <el-table
          :data="tableData"
          border
          style="width: 100%">
          <el-table-column
            prop="CourseNumber"
            label="课程号"
            width="100">
          </el-table-column>
          <el-table-column
            prop="CourseName"
            label="课程名称"
            width="100">
          </el-table-column>
          <el-table-column
            prop="Credit"
            label="学分"
            width="100">
          </el-table-column>
          <el-table-column
            prop="TotalHours"
            label="总学时"
            width="100">
          </el-table-column>
          <el-table-column
            prop="ExaminationForm"
            label="考试形式"
            width="100">
          </el-table-column>
          <el-table-column
            prop="TeachingMethods"
            label="授课方式"
            width="100">
          </el-table-column>
          <el-table-column
            prop="NoCourseNumber"
            label="不能排课节次"
            width="120">
          </el-table-column>
          <el-table-column
            prop="PracticeHours"
            label="优先排课节次"
            width="120">
          </el-table-column>
          <el-table-column
            prop="Status"
            label="进度"
            width="100">
          </el-table-column>
          <el-table-column
            label="操作"
            width="100">
            <template slot-scope="scope">
              <el-button @click="handleClick(scope.row)" type="text" size="small">查看</el-button>
            </template>
          </el-table-column>
        </el-table>
      </div>
    </el-card>
    <div class="look-dialog">
      <el-dialog title="提示" :visible.sync="dialogPlanVisible" width="98%" custom-class="add-course-dialog">
        <div>查看显示的详细内容，暂时不知道哪个接口</div>
        <div slot="footer" class="dialog-footer">
          <el-button @click="dialogPlanVisible = false">取 消</el-button>
          <el-button type="primary" @click="dialogPlanVisible = false">确 定</el-button>
        </div>
      </el-dialog>
    </div>
  </div>
</template>

<style lang="scss" scoped>
  .jxkcsh {
    .select-module {
      .select-item {
        display: inline-block;
        margin-right: 30px;
        .el-select, .el-input {
          width: 150px;
        }
      }
    }
    .but-group-module {
      margin-bottom: 10px;
    }
    .table-module {
      text-align: center;
      /*padding: 10px;*/
      border: 1px solid #ccc;
    }
    .add-course-dialog {
      .content {
        .el-input {
          width: 200px;
          display: inline-block;
        }
        .el-select {
          width: 200px;
        }
        .el-textarea {
          max-width: 650px;
        }
        .item {
          margin-bottom: 10px;
          span {
            display: inline-block;
            width: 100px;
          }
        }
      }
      .el-dialog__body {
        padding: 15px 20px;
      }
    }
    .red-tips {
      color: #f33;
    }
  }
</style>

<script>
  import {getToken} from "../../utils/auth";

  export default {
    data() {
      return {
        coursevalue1: '',
        coursevalue4: '',
        optionsValue1: [
          {
            value: '必修课程',
            label: '必修课程'
          },
          {
            value: '选修课程',
            label: '选修课程'
          }
        ],
        tableData: [],
        currentPageValue: 1, // 当前第几页
        pageNum: 10, // 每页数量
        totalData: '',
        dialogPlanVisible: false,
        // dialogAddVisible: false,
        // 弹框里的值
        value1: '',
        value1Options: [
          {
            value: '选修课程',
            label: '选修课程',
          },
          {
            value: '必修课程',
            label: '必修课程',
          }
        ],
        value2: '',
        value2Options: [
          {
            value: '选修课程',
            label: '选修课程',
          },
          {
            value: '必修课程',
            label: '必修课程',
          }
        ],
        value3: '',
        value4: '',
        value5: '',
        value6: '',
        value7: '',
        value8: '',
        value8Options: [
          {
            value: '选修课程',
            label: '选修课程',
          },
          {
            value: '必修课程',
            label: '必修课程',
          }
        ],
        value9: '',
        value10: '',
        value10Options: [
          {
            value: '选修课程',
            label: '选修课程',
          },
          {
            value: '必修课程',
            label: '必修课程',
          }
        ],
        value11: '',
        value11Options: [
          {
            value: '选修课程',
            label: '选修课程',
          },
          {
            value: '必修课程',
            label: '必修课程',
          }
        ],
        value12: '',
        value13: '',
        value14: '',
        value15: '',
        value16: '',
        value17: '',
        value18: '',
        value19: '',
        value20: '',
      }
    },
    methods: {
      handleClick(params) {
        this.dialogPlanVisible = true
      },
      findQuery() {
        this.loadTableData()
      },
      clearParams() {
        this.coursevalue1 = ''
        this.coursevalue4 = ''
      },
      // addApply() {
      //   this.dialogAddVisible = true
      // },
      async loadTableData() {
        let params = {
          token: getToken(),
          index: this.currentPageValue,
          pagemax: this.pageNum,
          category: this.coursevalue1,
          name: this.coursevalue4,
        }
        let res = await this.axios.get('v1/jxkc/getdata', {params: params})
        // console.log('哈哈')
        // console.log(res)
        let resData = res.data
        this.tableData = resData.data
        this.totalData = resData.count
        // console.log(this.tableData)
      },
      // async saveApplyData() {
      //   this.dialogAddVisible = false
      //   let params = {
      //     token: getToken(),
      //     electiveCategory: this.value1,
      //     CourseCategory: this.value1,
      //     CourseId: this.value1,
      //     CourseName: this.value1,
      //     CourseEnName: this.value1,
      //     CourseAlias: this.value1,
      //     CourseCost: this.value1,
      //     OpeningInstitution: this.value1,
      //     OpeningCoefficient: this.value1,
      //     ExaminationForm: this.value1,
      //     TeachingMethods: this.value1,
      //     TotalHours: this.value1,
      //     TheoreticalHours: this.value1,
      //     PracticeHours: this.value1,
      //     OtherHours: this.value1,
      //     Bibliography: this.value1,
      //     Credit: this.value1,
      //     CourseIntroduction: this.value1,
      //     CourseNumber: this.value1,
      //     NoCourseNumber: this.value1,
      //   }
      //   let res = await this.axios.post('v1/jxkc/add_action', params)
      //   console.log('申请保存')
      //   console.log(res)
      //   if (res.data.code === 200) {
      //     this.$message({
      //       message: '保存成功',
      //       type: 'success'
      //     });
      //   }
      // }
    },
    created() {
      this.loadTableData()
    }
  }
</script>
